package org.yejiali.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.yejiali.common.constants.SystemConstants;
import org.yejiali.common.response.ResponseResult;
import org.yejiali.domain.entity.Link;
import org.yejiali.domain.vo.LinkVo;
import org.yejiali.mapper.LinkMapper;
import org.yejiali.service.LinkService;

import java.util.List;

/**
 * 友链(Link)表服务实现类
 *
 * @author yejiali
 * @since 2025-02-18 14:46:47
 */
@Service("linkService")
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {
 @Override
 public ResponseResult getAllLink() {
  //查询所有审核通过的友链
  LambdaQueryWrapper<Link> lambdaQueryWrapper=new LambdaQueryWrapper<>();
  lambdaQueryWrapper.eq(Link::getStatus, SystemConstants.LINK_STATUS_NORMAL);
  List<Link> list = list(lambdaQueryWrapper);
  //转换为Vo
  List<LinkVo> linkVos = BeanUtil.copyToList(list, LinkVo.class);
  //封装返回
  return ResponseResult.okResult(linkVos);
 }
}


